//导入界面Form

Ext.onReady(function() {	
			//导入界面
			AgencyManage_SelectImportWin = Ext.create('Ext.form.Panel', {
						//AgencyManage_SelectImportWin = Ext.create('Ext.window.Window', {
						title : 'Excel导入',
						width : 500,
						id : 'AgencyManage_ExcelForm',
						height : 150,
						layout : {
							type : 'vbox',
							align : 'center'
						},
						modal : true,
						closeAction : 'hide',
						buttonAlign : "center",
						items : [{
							xtype : 'filefield',
							id : 'excelfile',
							name : 'excelfile',
							// fieldLabel: '选择文件',
							labelWidth : 50,
							msgTarget : 'side',
							allowBlank : false,
							anchor : '100%',
							buttonText : '请选择文件',
							listeners : {
								change : onuserImportChange
								//scope: me
							}

						}],
						buttons : [{
							text : '导入',
							minWidth : 70,
							handler : ImportExcel
								//scope: me
							}, {
							text : '取消',
							minWidth : 70,
							handler : CloseAgencyManage_SelectImportWin
								//scope: me
							}],
						renderTo : Ext.getBody()
					});

			//点击开始导入数据
			function AddAgencyInfoClick() {
				var me = this;
				AgencyManage_SelectImportWin.show();
			}

			//关闭导入界面
			function CloseAgencyManage_SelectImportWin() {
				var me = this;
				AgencyManage_SelectImportWin.hide();
			}

			//验证导入文件的格式
			function onuserImportChange() {
				var filenPath = Ext.getCmp("excelfile").getValue();
				fileExtension = filenPath.substring(filenPath.lastIndexOf('.'))
						.toLowerCase();
				if (fileExtension != ".xls") {
					Ext.Msg.show({
								title : '警告',
								msg : '选择的文件必须是xls格式的',
								buttons : '确定'
							});
				}
			}
			//导入Excel文件
			function ImportExcel() {
				var excelForm = Ext.getCmp('AgencyManage_ExcelForm').getForm();
				if (excelForm.isValid) {
					excelForm.submit({
								url : '/articles/importExcel.do',
								method : 'POST',
								waitMsg : '正在导入',
								success : function(form, action) {
									Ext.Msg.alert("导入成功！");

								},
								failure : function(form, action) {
									Ext.Msg.alert("导入失败！");
								}
							});
				}
			}

		});
